from django.db import models

# Create your models here.
#视频列表信息
class Video(models.Model):
    objects = models.Manager()
    id = models.AutoField(verbose_name='文件id',primary_key=True)
    order_number = models.IntegerField(verbose_name='序号',null=True,blank=True)
    role_id = models.IntegerField(verbose_name='主演名称id')
    show_role_ids = models.CharField(verbose_name='show_role_ids',max_length=100,null=True,blank=True)
    video_label_id = models.CharField(verbose_name='视频类型id',max_length=255,null=True,blank=True) #如厨房、客厅、教室...,用/号分隔
    introduction = models.TextField(verbose_name='简介',null=True,blank=True)
    designation = models.CharField(verbose_name='番号',max_length=255,null=True,blank=True)
    designation_name = models.CharField(verbose_name='番号后面的名称',max_length=255,null=True,blank=True)
    name = models.CharField(verbose_name='文件名称',max_length=255,null=True,blank=True)
    suffix_id = models.IntegerField(verbose_name='文件后缀id',null=True,blank=True)
    watermark = models.IntegerField(verbose_name='水印',default=0)
    resolving_power = models.CharField(verbose_name='分辨率',max_length=30,null=True,blank=True)
    mosaic = models.SmallIntegerField(verbose_name='马赛克',null=True,blank=True)
    subtitle = models.SmallIntegerField(verbose_name='字幕',null=True,blank=True)
    size = models.CharField(verbose_name='总文件大小',max_length=255,null=True,blank=True)
    length = models.CharField(verbose_name='总时长',max_length=255,null=True,blank=True)
    star = models.SmallIntegerField(verbose_name='评分',null=True,blank=True)
    is_del = models.SmallIntegerField(verbose_name='删除',default=0)
    include_time = models.DateTimeField(verbose_name='收录时间',auto_now_add=True)
    update_time = models.DateTimeField(verbose_name='更新时间',auto_now=True)
    #序列化函数str  在Python2中用__unicode__代替__str__
    def __str__(self):
        return self.name
    class Meta:
        #别名
        verbose_name = '番号'
        #更改复数显示方式
        verbose_name_plural = "番号"

#视频路径表，因为一个视频名下可能存在多个视频文件
class VideoPath(models.Model):
    objects = models.Manager()
    id = models.AutoField(verbose_name='路径id',primary_key=True)
    video_id = models.IntegerField(verbose_name='视频id',null=True,blank=True)
    role_id = models.IntegerField(verbose_name='主演名称id',null=True,blank=True)
    name = models.CharField(verbose_name='名称',max_length=255,null=True,blank=True)
    path = models.CharField(verbose_name='文件路径',max_length=255,null=True,blank=True)
    suffix_id = models.IntegerField(verbose_name='文件后缀id',null=True,blank=True)
    size = models.CharField(verbose_name='文件大小',max_length=255,null=True,blank=True)
    length = models.CharField(verbose_name='时长',max_length=255,null=True,blank=True)
    is_del = models.SmallIntegerField(verbose_name='删除',default=0)
    include_time = models.DateTimeField(verbose_name='收录时间',auto_now_add=True)
    update_time = models.DateTimeField(verbose_name='更新时间',auto_now=True)
    
    def __str__(self):
        return self.name
    class Meta:
        #别名
        verbose_name = '视频'
        #更改复数显示方式
        verbose_name_plural = "视频"

#视频标签
class VideoLabel(models.Model):
    objects = models.Manager()
    video_label_id = models.AutoField(verbose_name='视频类型id',primary_key=True)
    name = models.CharField(verbose_name='名称',max_length=255)
    is_del = models.SmallIntegerField(verbose_name='删除',default=0)
    create_time = models.DateTimeField(verbose_name='创建时间',auto_now_add=True)
    update_time = models.DateTimeField(verbose_name='更新时间',auto_now=True)
    def __str__(self):
        return self.name
    class Meta:
        #别名
        verbose_name = '标签'
        #更改复数显示方式
        verbose_name_plural = "标签"
#演员表
class Role(models.Model):
    objects = models.Manager()
    area_choices = (
        ('1','日本'),
        ('2','欧美'),
        ('3','韩国'),
        ('4','中国香港'),
        ('5','中国')
    )
    role_id = models.AutoField(verbose_name='演员id',primary_key=True)
    order_number = models.IntegerField(verbose_name='演员排序',null=True,blank=True)
    chinese_name = models.CharField(verbose_name='中文名称',max_length=255)
    real_name = models.CharField(verbose_name='原名',max_length=255,null=True,blank=True)
    old_names = models.CharField(verbose_name='曾用名',max_length=255,null=True,blank=True)
    photo = models.CharField(verbose_name='照片',max_length=255,null=True,blank=True)
    path = models.CharField(verbose_name='演员的文件路径',max_length=255,null=True,blank=True)
    #番号数量与视频数量可能不同，因为一个番号可能拆分为几个视频
    include_fanhao = models.IntegerField(verbose_name='已收番号数量',null=True,blank=True)
    include_number = models.IntegerField(verbose_name='已收录视频数量',null=True,blank=True)
    area = models.CharField(max_length=1,choices=area_choices,verbose_name='地区',default=1)
    star = models.SmallIntegerField(verbose_name='演员评分',null=True,blank=True)
    is_del = models.SmallIntegerField(verbose_name='删除',default=0)
    create_time = models.DateTimeField(verbose_name='创建时间',auto_now_add=True)
    update_time = models.DateTimeField(verbose_name='更新时间',auto_now=True)
    def __str__(self):
        return self.chinese_name

    class Meta:
        #别名
        verbose_name = '演员'
        #更改复数显示方式
        verbose_name_plural = "演员"
    

#视频格式类型列表/视频后缀，如mp4、avi...
class VideoSuffix(models.Model):
    objects = models.Manager()
    suffix_id = models.AutoField(verbose_name='视频后缀id',primary_key=True)
    name = models.CharField(verbose_name='名称',max_length=255)
    is_del = models.SmallIntegerField(verbose_name='删除',default=0)
    create_time = models.DateTimeField(verbose_name='创建时间',auto_now_add=True)
    update_time = models.DateTimeField(verbose_name='更新时间',auto_now=True)

    def __str__(self):
        return self.name
    class Meta:
        #别名
        verbose_name = '格式'
        #更改复数显示方式
        verbose_name_plural = "格式"